<?php
/**
 * Created by PhpStorm.
 * User: gaochaolyf
 * Date: 16/5/30
 * Time: 下午3:09
 */

namespace home\Model;
use Think\Model;

class ResEntityModel extends Model
{
    function __construct() {
        $this->model = M('ResEntity');
    }

    public function getResList($field = array('*'), $condition = array(), $page = 1, $pergage = 20, $order = 'rid ASC') {
        $data = $this->model->where($condition)->field($field)->page($page, $pergage)->order($order)->select();
        $data = $data ? $data : array();

        return $data;
    }

    public function getOneRes($field = array('*'), $condition = array()) {
        $data = $this->model->where($condition)->field($field)->find();
        $data = $data ? $data : array();

        return $data;
    }

    public function addOneRes($param = array()) {
        $insert_id = $this->model->data($param)->add();

        return $insert_id;
    }

    public function updateOneRes($param = array(), $condition = array()) {
        $affected = $this->model->where($condition)->setField($param);

        return $affected;
    }
	
}

?>